/*    */ package com.finir.finknjig.service;
/*    */ 
/*    */ import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import com.finir.finknjig.domain.Nalog;
import com.finir.finknjig.domain.Preduzece;
import com.finir.finknjig.persistence.hibernate.HibernatePersistenceManager;
import com.finir.finknjig.variables.StaticVariables;
/*    */ 
/*    */ public class NalogFacade
/*    */ {
/*    */   HibernatePersistenceManager pm;
/*    */ 
/*    */   public NalogFacade()
/*    */   {
/* 19 */     this.pm = new HibernatePersistenceManager();
/*    */   }
/*    */ 
/*    */   public List<Nalog> vratiSveNaloge(Integer year, Preduzece preduzece)
/*    */   {
/* 25 */     if ((StaticVariables.getPreduzece() != null) && 
/* 26 */       (StaticVariables.getGodina() != null)) {
/* 27 */       String hql = "from NalogBean n where extract(year from n.datumNaloga)=? and n.preduzece=?";
/* 28 */       List param = new LinkedList();
/* 29 */       param.add(year);
/* 30 */       param.add(preduzece);
/* 31 */       return this.pm.executeQuery(Nalog.class, hql, param);
/*    */     }
/* 33 */     return null;
/*    */   }
/*    */ 
/*    */   public Integer dajBrojNaloga()
/*    */   {
/* 39 */     if ((StaticVariables.getPreduzece() != null) && 
/* 40 */       (StaticVariables.getGodina() != null)) {
/* 41 */       String hql = "select max(n.brojNaloga) from NalogBean n where extract(year from n.datumNaloga)=? and n.preduzece=?";
/* 42 */       List param = new LinkedList();
/* 43 */       param.add(StaticVariables.getGodina());
/* 44 */       param.add(StaticVariables.getPreduzece());
/*    */ 
/* 46 */       Integer ret = (Integer)this.pm.returnUniqueResult(Integer.class, hql, param);
/*    */ 
/* 48 */       if (ret == null)
/* 49 */         return Integer.valueOf(1);
/*    */ 
/* 51 */       return Integer.valueOf(ret.intValue() + 1);
/*    */     }
/*    */ 
/* 54 */     return null;
/*    */   }
/*    */ 
/*    */   public List<Nalog> vratiSveNalogeIzmedjuDatuma(Date odDatum, Date doDatum)
/*    */   {
/* 60 */     if ((StaticVariables.getPreduzece() != null) && 
/* 61 */       (StaticVariables.getGodina() != null))
/*    */     {
/* 63 */       String hql = "from NalogBean n where extract(year from n.datumNaloga)=? and n.preduzece=? and n.datumNaloga between ? and ?";
/*    */ 
/* 65 */       List param = new ArrayList();
/* 66 */       param.add(StaticVariables.getGodina());
/* 67 */       param.add(StaticVariables.getPreduzece());
/* 68 */       param.add(odDatum);
/* 69 */       param.add(doDatum);
/*    */ 
/* 71 */       return this.pm.executeQuery(Nalog.class, hql, param);
/*    */     }
/* 73 */     return null;
/*    */   }
/*    */ }

